package org.bai.algorithm.util;

import org.bai.algorithm.entity.ListNode;

import java.util.StringJoiner;

public class RevealUtil {

    public static void reveal(int[] nums) {
        StringJoiner joiner = new StringJoiner(", ", "[", "]");
        for (int i = 0; i < nums.length; i++) {
            joiner.add(String.valueOf(nums[i]));
        }
        System.out.println(joiner.toString());
    }

    public static void reveal(ListNode<Integer> listNode) {
        if (null != listNode) {
            ListNode<Integer> temporary = listNode;
            StringJoiner joiner = new StringJoiner(" -> ");
            do{
                if (null != temporary.val) {
                    joiner.add(temporary.toString());
                }
                temporary = temporary.next;
            } while (null != temporary);
            System.out.println(joiner.toString());
        }
    }

}
